public class Login {
    public String name = "admin";
    public String password = "123456";

    public void loginInfo(String name, String password) throws UserNameException, PasswordException{
        if(this.name != name){
            throw new UserNameException("用户名错误");
        }
        if(this.password != password){
            throw new PasswordException("密码错误");
        }
        System.out.println("登录成功");
    }

    public static void main(String[] args) {
        try{
            Login login = new Login();
            login.loginInfo("admi2n","123456");
        }catch (UserNameException e) {
            e.printStackTrace();
            System.out.println("用户名yichang");
        }catch (PasswordException e){
            e.printStackTrace();
            System.out.println("密码错误");
        }finally{
            System.out.println("hhhh");
        }
    }
}
